<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    function fn() {
        this.num = 10;
        console.log(this);
    }
    fn.num = 20;
    fn.prototype.num = 30;
    fn.prototype.method = function () {
        console.log(this.num);
    }
    var prototype = fn.prototype;
    var method = prototype.method;

    new fn().method();      //10
    prototype.method();     //30
    method();               //this指向window     undefined

    var obj = new fn();     //obj   fn:{}
    /*
        new 运算符做了以下事情
        1、调用函数
        2、自动创建一个对象
        3、把创建出来的对象和this进行绑定
        4、如果构造函数没有返回值，隐式返回this对象
    */



</script>

</html>